#include <assert.h>

#include <iostream>
#include <iosfwd>
#include <stdexcept>
#include <array>

#include <boost/lexical_cast.hpp>

class negative_number {
	unsigned short number_;
public:
	negative_number() : number_(0)
	{}

	explicit negative_number(unsigned short number)
		: number_(number)
	{}

	unsigned short value_without_sign() const {
		return number_;
	}
};

std::ostream& operator<<(std::ostream& os, const negative_number& num)
{
	os << '-' << num.value_without_sign();
	return os;
}

std::istream& operator>>(std::istream& is, negative_number& num) {
	char ch;
	is >> ch;
	if (ch != '-') {
		throw std::logic_error("negative_number class designed to store ONLY negative values");
	}
	unsigned short s;
	is >> s;
	num = negative_number(s);
	return is;
}

int main()
{
	negative_number n = boost::lexical_cast<negative_number>("-100");
	std::cout << "==== 1 ====" << "    " << std::endl
		<< "n.value_without_sign():" << n.value_without_sign() << "    " << std::endl;

	int i = boost::lexical_cast<int>(n);
	std::cout << "==== 2 ====" << "    " << std::endl
		<< "i:" << i << "    " << std::endl;

	typedef std::array<char, 10> arr_t;
	arr_t arr = boost::lexical_cast<arr_t>(n);
	std::cout << "==== 3 ====" << "    " << std::endl
		<< "arr[0]:" << arr[0] << "    "
		<< "arr[1]:" << arr[1] << "    "
		<< "arr[2]:" << arr[2] << "    "
		<< "arr[3]:" << arr[3] << "    "
		<< "arr[4]:" << arr[4] << "    "
		<< std::endl;

	return 0;
}